﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;

namespace Noris.Tools.TraceVisualiser.Components
{
    #region DPanel : Panel s implementovaným ToolTipem
    /// <summary>
    /// DPanel : Panel s implementovaným ToolTipem
    /// </summary>
    public class DPanel : Panel
    {
        #region Konstrukce
        public DPanel()
        {
            InitializeComponent();
        }
        /// <summary>
        /// Sestavení controlu
        /// </summary>
        private void InitializeComponent()
        {
            this.ToolTip = new TraceVisualiser.Components.DToolTip();
        }
        protected Noris.Tools.TraceVisualiser.Components.DToolTip ToolTip;
        #endregion
        #region Tooltip - existence
        /// <summary>
        /// Druh tooltipu
        /// </summary>
        [Category("DPanel")]
        [DefaultValue(TooltipMode.Simple)]
        [Description("Zjednodušené nastavení vlastností tooltipu")]
        public TooltipMode CurrentTooltipMode
        {
            get { return this.ToolTip.CurrentTooltipMode; }
            set { this.ToolTip.CurrentTooltipMode = value; }
        }
        /// <summary>
        /// Objekt tooltipu
        /// </summary>
        [Category("DPanel")]
        [Description("Objekt tooltipu pro plné nastavení jeho vlastností")]
        public DToolTip ToolTipForm { get { return this.ToolTip; } }
        #endregion
        #region Tooltip - používání: přechodníky na metody ToolTipu
        /// <summary>
        /// Nastaví tooltip na defaltní hodnoty
        /// </summary>
        /// <param name="tt"></param>
        public void ResetToolTipSettings()
        {
            this.ToolTip.ResetToolTipSettings();
        }
        /// <summary>
        /// Skryje text ToolTip, například při odchodu z prostoru
        /// </summary>
        /// <param name="message"></param>
        public void ToolTipHide()
        {
            this.ToolTip.ToolTipHide();
        }
        /// <summary>
        /// Zobrazí text ToolTip
        /// </summary>
        /// <param name="message"></param>
        public void ToolTipShow(Control control, string message)
        {
            this.ToolTip.ToolTipShow(control, message);
        }
        /// <summary>
        /// Zobrazí text ToolTip
        /// </summary>
        /// <param name="message"></param>
        public void ToolTipShow(string message, string titleText)
        {
            this.ToolTip.ToolTipShow(this, message, titleText);
        }
        /// <summary>
        /// Zobrazí text ToolTip
        /// </summary>
        /// <param name="message"></param>
        public void ToolTipShow(string message, ToolTipIcon icon, string titleText)
        {
            this.ToolTip.ToolTipShow(this, message, icon, titleText);
        }
        /// <summary>
        /// Nastaví veškeré vlastnosti ToolTipu na defaultní.
        /// Pokud uživatel dříve (v rámci this) neměnil vlastnosti ToolTipu, pak není zapotřebí je nastavovat na default, to je provedeno vždy implicitně před prvním použitím.
        /// </summary>
        public void ToolTipSetDefault()
        {
            this.ToolTip.ToolTipSetDefault();
        }
        /// <summary>
        /// Uloží do tooltipu text, který se bude zobrazovat standardně pro zadaný control
        /// </summary>
        /// <param name="control"></param>
        /// <param name="caption"></param>
        public void ToolTipForControl(Control control, string message)
        {
            this.ToolTip.ToolTipForControl(control, message);
        }
        /// <summary>
        /// Titulek tooltipu
        /// </summary>
        public string ToolTipTitle
        {
            get { return this.ToolTip.ToolTipTitle; }
            set { this.ToolTip.ToolTipTitle = value; }
        }
        /// <summary>
        /// Nastaví parametry ToolTipu
        /// </summary>
        /// <param name="automaticDelay">Sets the automatic delay for the ToolTip. in milliseconds. The default is 500.</param>
        /// <param name="initialDelay">Sets the time that passes before the ToolTip appears. The period of time, in milliseconds, that the pointer must remain stationary on a control before the ToolTip window is displayed.</param>
        /// <param name="autoPopDelay">Sets the period of time the ToolTip remains visible if the pointer is stationary on a control with specified ToolTip text. in milliseconds. The default value is 5000.</param>
        /// <param name="reshowDelay">Sets the length of time that must transpire before subsequent ToolTip windows appear as the pointer moves from one control to another. The length of time, in milliseconds, that it takes subsequent ToolTip windows to appear.</param>
        /// <param name="showAlways">Gets or sets a value indicating whether a ToolTip window is displayed, even when its parent control is not active. true if the ToolTip is always displayed; otherwise, false. The default is false.</param>
        public void ToolTipSet(int automaticDelay, int initialDelay, int autoPopDelay, int reshowDelay, bool showAlways)
        {
            this.ToolTip.ToolTipSet(automaticDelay, initialDelay, autoPopDelay, reshowDelay, showAlways);
        }
        /// <summary>
        /// Nastaví parametry ToolTipu
        /// </summary>
        /// <param name="isBalloon">Sets a value indicating whether the ToolTip should use a balloon window. true if a balloon window should be used; otherwise, false if a standard rectangular window should be used. The default is false.</param>
        /// <param name="backColor">The background color for the ToolTip.</param>
        /// <param name="foreColor">The foreground color for the ToolTip.</param>
        protected void ToolTipSet(bool isBalloon, Color backColor, Color foreColor)
        {
            this.ToolTip.ToolTipSet(isBalloon, backColor, foreColor);
        }
        /// <summary>
        /// Nastaví parametry ToolTipu
        /// </summary>
        /// <param name="isBalloon">Sets a value indicating whether the ToolTip should use a balloon window. true if a balloon window should be used; otherwise, false if a standard rectangular window should be used. The default is false.</param>
        /// <param name="backColor">The background color for the ToolTip.</param>
        /// <param name="foreColor">The foreground color for the ToolTip.</param>
        /// <param name="icon">Sets a value that defines the type of icon to be displayed alongside the ToolTip text</param>
        /// <param name="titleText">Sets a title for the ToolTip window.</param>
        protected void ToolTipSet(bool isBalloon, Color backColor, Color foreColor, ToolTipIcon icon, string titleText)
        {
            this.ToolTip.ToolTipSet(isBalloon, backColor, foreColor, icon, titleText);
        }
        #endregion
    }
    #endregion
    #region DControl : Control s implementovaným ToolTipem
    /// <summary>
    /// DControl : Control s implementovaným ToolTipem
    /// </summary>
    internal class DControl : Control
    {
        #region Konstrukce a používání
		public DControl()
		{
			this._ToolTip = new DToolTip();
			this._ToolTip.CurrentTooltipMode = TooltipMode.Baloon;
		}
        /// <summary>
        /// Zobrazování tooltipu = informace podle gusta majitele Controlu
        /// </summary>
        private DToolTip _ToolTip;
        /// <summary>
        /// ToolTip v rámci tohoto Controlu.
        /// Dokud není použit, je null. Instancuje se prvním použitím.
        /// Vlastnosti je možno nastavovat buď jednotlivě (přes jejich property), anebo využitím metody ToolTipSet(...).
        /// Zobrazování je třeba řídit programem (typicky odvozeno od pohybu myši), zavoláním metody ToolTipShow().
        /// </summary>
        protected DToolTip ToolTip
        {
            get
            {
                if (_ToolTip == null)
                    _ToolTip = new DToolTip();
                return _ToolTip;
            }
        }
        #endregion
        #region Používání
        /// <summary>
        /// Skryje text ToolTip, například při odchodu z prostoru
        /// </summary>
        /// <param name="message"></param>
        protected void ToolTipHide()
        {
            this.ToolTip.ToolTipHide();
        }
        /// <summary>
        /// Zobrazí text ToolTip
        /// </summary>
        /// <param name="message"></param>
        protected void ToolTipShow(string message)
        {
            this.ToolTip.ToolTipShow(this, message);
        }
        /// <summary>
        /// Zobrazí text ToolTip
        /// </summary>
        /// <param name="message"></param>
        protected void ToolTipShow(string message, string titleText)
        {
            this.ToolTip.ToolTipShow(this, message, titleText);
        }
        /// <summary>
        /// Zobrazí text ToolTip
        /// </summary>
        /// <param name="message"></param>
        protected void ToolTipShow(string message, ToolTipIcon icon, string titleText)
        {
            this.ToolTip.ToolTipShow(this, message, icon, titleText);
        }
        /// <summary>
        /// Nastaví veškeré vlastnosti ToolTipu na defaultní.
        /// Pokud uživatel dříve (v rámci this) neměnil vlastnosti ToolTipu, pak není zapotřebí je nastavovat na default, to je provedeno vždy implicitně před prvním použitím.
        /// </summary>
        protected void ToolTipSetDefault()
        {
            this.ToolTip.ToolTipSetDefault();
        }
        /// <summary>
        /// Uloží do tooltipu text, který se bude zobrazovat standardně pro zadaný control
        /// </summary>
        /// <param name="control"></param>
        /// <param name="caption"></param>
        protected void ToolTipForControl(Control control, string message)
        {
            this.ToolTip.ToolTipForControl(control, message);
        }
        /// <summary>
        /// Titulek tooltipu
        /// </summary>
        protected string ToolTipTitle
        {
            get { return this.ToolTip.ToolTipTitle; }
            set { this.ToolTip.ToolTipTitle = value; }
        }
        /// <summary>
        /// Nastaví parametry ToolTipu
        /// </summary>
        /// <param name="automaticDelay">Sets the automatic delay for the ToolTip. in milliseconds. The default is 500.</param>
        /// <param name="initialDelay">Sets the time that passes before the ToolTip appears. The period of time, in milliseconds, that the pointer must remain stationary on a control before the ToolTip window is displayed.</param>
        /// <param name="autoPopDelay">Sets the period of time the ToolTip remains visible if the pointer is stationary on a control with specified ToolTip text. in milliseconds. The default value is 5000.</param>
        /// <param name="reshowDelay">Sets the length of time that must transpire before subsequent ToolTip windows appear as the pointer moves from one control to another. The length of time, in milliseconds, that it takes subsequent ToolTip windows to appear.</param>
        /// <param name="showAlways">Gets or sets a value indicating whether a ToolTip window is displayed, even when its parent control is not active. true if the ToolTip is always displayed; otherwise, false. The default is false.</param>
        protected void ToolTipSet(int automaticDelay, int initialDelay, int autoPopDelay, int reshowDelay, bool showAlways)
        {
            this.ToolTip.ToolTipSet(automaticDelay, initialDelay, autoPopDelay, reshowDelay, showAlways);
        }
        /// <summary>
        /// Nastaví parametry ToolTipu
        /// </summary>
        /// <param name="isBalloon">Sets a value indicating whether the ToolTip should use a balloon window. true if a balloon window should be used; otherwise, false if a standard rectangular window should be used. The default is false.</param>
        /// <param name="backColor">The background color for the ToolTip.</param>
        /// <param name="foreColor">The foreground color for the ToolTip.</param>
        protected void ToolTipSet(bool isBalloon, Color backColor, Color foreColor)
        {
            this.ToolTip.ToolTipSet(isBalloon, backColor, foreColor);
        }
        /// <summary>
        /// Nastaví parametry ToolTipu
        /// </summary>
        /// <param name="isBalloon">Sets a value indicating whether the ToolTip should use a balloon window. true if a balloon window should be used; otherwise, false if a standard rectangular window should be used. The default is false.</param>
        /// <param name="backColor">The background color for the ToolTip.</param>
        /// <param name="foreColor">The foreground color for the ToolTip.</param>
        /// <param name="icon">Sets a value that defines the type of icon to be displayed alongside the ToolTip text</param>
        /// <param name="titleText">Sets a title for the ToolTip window.</param>
        protected void ToolTipSet(bool isBalloon, Color backColor, Color foreColor, ToolTipIcon icon, string titleText)
        {
            this.ToolTip.ToolTipSet(isBalloon, backColor, foreColor, icon, titleText);
        }
        #endregion
    }
    #endregion
}
